﻿Imports System.Data.SqlClient
Public Class Selereport
    Dim cmd As New SqlCommand
    Public Sub refreshdata()
        grdsale.Rows.Clear()
        condb()
        cmd.Connection = cn
        cmd.CommandText = "select o.InvoiceID ,o.orderDate  , ProName,Qty from tblorder o inner join tblorderDetial od ON o.InvoiceID = od.InvoiceID where o.orderDate between '" & startdate.Value & "' and '" & enddate.Value & "' and ProName like '%" & txtsearch.Text & "%'"
        Dim dr = cmd.ExecuteReader
        While dr.Read = True
            grdsale.Rows.Add(dr(0), dr(1), dr(2), dr(3))
        End While
        dr.Close()
    End Sub
    Private Sub Selereport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        condb()
    End Sub

    Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged
        refreshdata()
        Dim p As Integer
        p = 0
        For i As Integer = 0 To Me.grdsale.Rows.Count - 1
            p = p + Me.grdsale.Rows(i).Cells(3).Value

        Next
        lbltotal.Text = p
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Dim frm As New saleGraphicChart
        frm.TopLevel = False
        Me.Panel1.Controls.Add(frm)
        frm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        frm.WindowState = FormWindowState.Maximized
        frm.Show()

    End Sub
End Class